﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ZK.Common
{

    public static class ShowBlackBox
    {
        /// <summary>  
                /// 输出信息  
                /// </summary>  
                /// <param name="format"></param>  
                /// <param name="args"></param>  
        public static void WriteLine(string format, params object[] args)
        {
            WriteLine(string.Format(format, args));
        }

        /// <summary>  
                /// 输出信息  
                /// </summary>  
                /// <param name="output">前面123 信息级别（一般，警告，错误）例：1 一般信息</param>  
        public static void WriteLine(string output)
        {
            Console.ForegroundColor = GetConsoleColor(output);
            Console.WriteLine(@"[{0}]{1}", DateTimeOffset.Now, output.Substring(1));
        }

        /// <summary>  
                /// 根据输出文本选择控制台文字颜色  
                /// </summary>  
                /// <param name="output"></param>  
                /// <returns></returns>  
        private static ConsoleColor GetConsoleColor(string output)
        {
            if (output.StartsWith("2"))
                return ConsoleColor.Yellow;
            if (output.StartsWith("3"))
                return ConsoleColor.Red;
            //if (output.StartsWith("1"))
            //    return ConsoleColor.Green;
            return ConsoleColor.Green;
        }
    }
}
